import { Component, OnInit } from '@angular/core';
import { CardIO } from '@ionic-native/card-io/ngx';
import { Router, NavigationExtras,ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-scan-card',
  templateUrl: './scan-card.page.html',
  styleUrls: ['./scan-card.page.scss'],
})
export class ScanCardPage implements OnInit {

  constructor(
    private cardIO: CardIO,
    private router: Router,
    private activatedRoute : ActivatedRoute
  ) {
    // this.cardIO.canScan()
    //   .then(
    //     (res: boolean) => {
    //       console.info("res 1 : ");
    //       console.info(res);
    //       if (res) {
    //         let options = {
    //           hideCardIOLogo:true,
    //           suppressScan:true,
    //           requireExpiry: true,
    //           requireCVV: false,
    //           requirePostalCode: false
    //         };
    //         // this.cardIO.scan(options,).then((response)=>{
    //         //   console.info('scan data : ');
    //         //   console.info(response);
    //         // },(err)=>{
    //         //   console.info('scan error 1 : ');
    //         //   console.info(err);
    //         // });
    //       }
    //     }
    //   );
      //扫描成功跳转
      this.activatedRoute.queryParams.subscribe(
        (data:any)=>{
          let navigationExtras: NavigationExtras = {
            queryParams: {
              bankName:data.bankName,
              cardNumber:'123456'
            } 
          };
          console.info(navigationExtras);
          this.router.navigate(['/tabs/myAccount/bank-account/add-bank-account'],navigationExtras);
        }
      )
  }

  ngOnInit() {
  }


}
